import * as type from '../appendType'

const state = {
  loadingState: false,
  wait: true,
  homeScroll: 0
}

const actions = {}

const getters = {
  loadingState: state => state.loadingState,
  getWait: state => state.wait
}

const mutations = {
  changeState(state, value) {
    state.loadingState = value
  },
  [type.WAIT_LOADING](state, value) {
    // 等待层关闭进行延迟处理
    if (!value) {
      setTimeout(() => {
        if (state.wait) {
          state.wait = value;
        }
      }, 500)
    } else {
      state.wait = value
    }
  },
  [type.HOME_SCROLL](state, value) {
    state.homeScroll = value;
  }
}

export default {
  state,
  actions,
  getters,
  mutations
}
